package com.ganbo.stock.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

/**
 * Created by gan on 2019/10/7 19:30.
 */

@Configuration
public class RestTemplateUtils {

    @Autowired
    RestTemplate restTemplate;

    public <T> T get(String serverUrl, Map<String, String> params, Class<T> respClass) {
        ResponseEntity<String> response = restTemplate.getForEntity(serverUrl, String.class, params);
        return FastJsonUtil.jsonStringToObject(response.getBody(), respClass);
    }


}
